﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Play.Master" Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Models.Play.PlayModel>" %>
<%@ Import Namespace="Code.Models" %>
<asp:Content ContentPlaceHolderID="TitleContent" runat="server">
    <%=Model.LotteryName %>
</asp:Content>


<asp:Content ID="Content1" ContentPlaceHolderID="PlayContent" runat="server">
<div class="play_content">
    <% Html.BeginForm("Index", "Play", FormMethod.Post, new { id="form_play_bet"}); %>
      <%--   <div class="play_bet_header">
            <table width="100%" height="42px" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="36px" ><span class='play_bet_header_ico'>&nbsp;</span></td>
                    <td align="left"><%=Model.LotteryName %></td>
                    <td ><span id="issuename">期号:载入中...</span></td>
                    <td><span id="issueend">截止时间:载入中...</span></td>
                    <td width="55px"><span class="play_head_lastwin_text">上期开奖:</span></td>
                    <td width="300px" valign="middle"><span id="issuewin">载入中...</span></td>
                </tr>
            </table>
        </div>--%>
           <div class="play_bet_body">
            <div class="play_bet_body_left">
                <div class="play_vedio" id="play_vedio">
                    <% Html.RenderPartial("Vedio2", new QianBuo.Lottery.Web.Models.Play.VedioModel { LotteryID = Model.LotteryID, LotteryName = Model.LotteryName, OpenCodeLen = Model.OpenCodeLen, StyleName = Model.OpenCodeLen > 5? "font_size_27px" : "font_size_32px" }); %>
                    <%--<iframe width="465" height="186" class="" scrolling="no" src='<%=Url.Action("Vedio", new { id = (LotteryType)Model.LotteryID })%>'></iframe>--%>
                </div>
                <div class="play_bet_playtype" id="play_bet_playtype">
                    <ul>
                        <%foreach (var n in Model.PlayType.GroupBy(p=>p.Value.Value))
                          {
                              var item = n.First().Value;
                        %>
                              <li <%=Model.PlayID.HasValue&&n.Select(p=>p.Value.Key).Contains(Model.PlayID.Value) ? " class = 'current'" : "" %>>
                                  <%=Html.RouteLink(item.Value, Model.IsSinglePlay ? "Play_Single" : "PlayType", (object)new { id = (LotteryType)Model.LotteryID, p1 = (PlayType_E)item.Key })%></li>
                        <%  } %>
                    </ul>
                </div>
                <div id="play_bet_bar">
                    <% if (Model.IsSinglePlay) { Html.RenderAction("Play", new { id = (LotteryType)Model.LotteryID, p1 = (PlayType_E)Model.PlayID }); }
                       else
                       {%>
                    <img alt="载入中..." src='<%=Url.Content("~/Content/images/busy.gif") %>' />
                    载入中...<%} %>
                </div>
                <div id="play_bet_multi">
                    <p>
                        <input type="checkbox" id="Bet_Chase" name="Bet.Chase" value="true" />
                        <input type="hidden" name="Bet.Chase" value="false" />
                        <label class="ischase" for="Bet_Chase">追号</label>
                        <span id="bet_chase_stopwin">
                            <input type="checkbox" name="Bet.StopWin" checked="checked" value="true" />
                            <input type="hidden" name="Bet.StopWin" value="false" />
                            <%--<%=Html.CheckBoxFor(p => p.Bet.StopWin, new {@checked="checked" })%>--%>
                            <%=Html.LabelFor(P=>P.Bet.StopWin) %>
                        </span>
                    </p>
                    <p>购买注数:<span id="bet_count">10000注</span></p>
                    <p id="bet_shememurliple">购买倍数:<input type="text" class="text_small" id="SingleMultiply" name="Bet.SingleMultiply" value='<%=Model.Bet.SingleMultiply %>' />倍</p>
                    <p>方案金额:<span id="bet_money">￥120,000,00</span></p>
                    <div id="play_validationsummary">
                        <%=Html.ValidationMessageFor(p=>p.Bet.SumMoney) %>
                        <%=Html.ValidationMessageFor(p => p.Bet.IssueID) %>
                        <%=Html.ValidationMessageFor(p => p.Bet.Chases) %>
                        <%=Html.ValidationMessage("PlayError")%>
                    </div>
                    <p style="text-align:center">
                         <input type="submit" class="btnbet" id="btnBet" value="" onclick="return btnBet_Click()" />
                    </p>
                    <p style="text-align:center">
                        <%=Html.ValidationMessageFor(p=>p.AccpetProtocol) %>
                        <input type="checkbox" checked="checked" id="AccpetProtocol" name="AccpetProtocol" value="True"/>
                        <%=Html.ActionLink("同意彩票购买协议", "Protocol", new { id="A"}, new { @class = "a_blue" }) %>
                    </p>
                    <div id="play_input_hidden">
                        <%=Html.TextBoxFor(p => p.Bet.SumMoney) %>
                        <%=Html.TextBoxFor(p => p.Bet.IssueID) %>

                        <%=Html.HiddenFor(p => p.LotteryID) %>
                        <%=Html.HiddenFor(p => p.LotteryName) %>
                        <%=Html.HiddenFor(p => p.SingleBetMoney) %>
                        <%=Html.HiddenFor(p => p.PlayID) %>
                    </div>
                </div>
                <div id="play_bet_backMoneyToWinMoney">
                    <table width="100%">
                        <tr>
                            <td width="80" title="剩余返点">返点:<font color="red" id="play_bet_backToWin_ratio">0%</font></td>
                            <td width="80" title="返点加奖">加奖:<font color="red" id="play_bet_backToWin_ratioTo">￥0</font></td>
                            <td width="23" align="left"><a id="play_bet_backToWin_sub" href="javascript:;">-</a></td>
                            <td><div id="play_bet_backToWin_slider"></div></td>
                            <td width="23" align="right"><a id="play_bet_backToWin_add" href="javascript:;">+</a></td>
                            <td width="90" align="right">奖金:<font color="red" id="play_bet_backToWin_win">￥0</font></td>
                        </tr>
                    </table>
                </div>
                <div id="play_bet_scheme">
                    <ul id="buys">
                        <li class="span title"><span class="l">投注项：<b id="BetListCount">4</b></span><span class="r btn" id="BetListDelete" title="删除全部">×</span></li>
                        <li class="span head"><span id="c1" class="span c1">&nbsp;&nbsp;玩法</span><span id="c2" class="span c2">号码</span><span id="c3" class="span c3">注数</span><span id="c4" class="span c4">金额</span><span id="c5" class="span c5" title="返点加奖">加奖</span><span id="c6" class="span c6">&nbsp</span></li>
                        <li class="span empry">无投注项...</li>
                    </ul>
                </div>
                <div id="play_bet_chase" style="display:none;">
                    <ul id="chases">
                        <li class="head">
                            <span class="span">起始:<select id="start_issue"><option selected="selected">期号载入中...</option></select></span>
                            <span class="span">追<input type="text" class="text_small" id="issue_count" />期<font color="#CCCCCC" id="issue_sumcount">(最多0期)</font></span>
                            <span class="span"><input type="checkbox" id="chase_tool_no" /><label for="chase_tool_no">倍投工具</label></span>
                        </li>
                        <li class="tool">
                                <span class="span">起始倍数：<input type="text" id="tool_startMul" class="text_small" value='1'/></span>
                                <table width="430px" bgcolor="#F6F6F6" align="center" id="tool_types">
                                <tr class="active">
                                    <td>
                                        <input type="radio" id="rdo_chase_tool_1" name="rdo_chase_tool_type" checked="checked" value='1'/>
                                        <span>全程利润率：<input name="p1" type="text" id="rdo_chase_tool_1_p1"  class="text80" value='10'/>%</span>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <input type="radio" id="rdo_chase_tool_2" name="rdo_chase_tool_type" value='2'/>
                                        <span>
                                            前<input name="p1"  type="text" id="rdo_chase_tool_2_p1"  class="text50" value='5' disabled="disabled"/>期利润率
                                            <input name="p2"  type="text" id="rdo_chase_tool_2_p2"  class="text50" value='10' disabled="disabled"/>%，之后利润率
                                            <input name="p3"  type="text" id="rdo_chase_tool_2_p3"  class="text50" value='5' disabled="disabled"/>%</span>
                                    </td>
                                </tr>
                                </table>
                                <div style="text-align:center;"><input type="button" id="tool_build"  value="生成计划" /></div>
                        </li>
                        <li class="title"><span class="span c1">&nbsp;&nbsp;&nbsp;<input type="checkbox" /></span><span class="span c2">期号</span><span class="span c3"><input type="text" class="text_small" />倍</span><span class="span c4">金额</span><span class="span c5">累积投入</span><span class="span c6">当期奖金</span><span class="span c7">利润率</span></li>
                        <li class="span empry">无追号项...</li>
                    </ul>
                </div>
            </div>
            <div class="play_bet_body_right">
                <div id="play_opencode_history" url='<%=Url.Action("OpenCodeHistory", new { id = Model.LotteryID }) %>'>
                    <% Html.RenderAction("OpenCodeHistory", new { id = Model.LotteryID }); %>
                </div>
            </div>
        </div>
    <% Html.EndForm(); %>
</div>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="StyleAndScript" runat="server">
    <link href='<%=Url.Content("~/Scripts/UI/blitzer/jquery-ui-1.8.custom.css") %>' rel="stylesheet" type="text/css" />
    <script src='<%=Url.Content("~/Scripts/jquery-ui-1.8.custom.min.js" ) %>'type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {

            Site.Lottery.SingleMoney = <%=Model.SingleBetMoney %>;
            Site.Lottery.BackMoneyToWinMoneyEnable = <%=Model.BackMoneyToWinMoneyEnable ? "true" : "false" %>;
            Site.Lottery.BackMoneyToWinMoneyStep = <%=Model.BackMoneyToWinMoneyStep %>;
            <% 
                switch ((Code.Models.LotteryType)Model.LotteryID)
                {
                   case Code.Models.LotteryType.CQSSC:
                   case Code.Models.LotteryType.JXSSC:
                   case Code.Models.LotteryType.HLJSSC:
                   case Code.Models.LotteryType.XJSSC:
            %>Site.Lottery.IsSSL = true;
            <%
                       break;
                   case Code.Models.LotteryType.SHSSL:
                   case Code.Models.LotteryType.FC3D:
                   case Code.Models.LotteryType.SZPL:
                   case Code.Models.LotteryType.GDKLSF:
            %>Site.Lottery.IsSSL = false;
            <%
                       break;
                   default:
                       break;
                }    
            %>

            $('#play_input_hidden').hide();
            var lotteryID = <%=Model.LotteryID %>;

            var sss = new Site.Lottery.Play(lotteryID, '<%=Model.LotteryName%>');
            sss.CurrentLottery.ForwardEnd = <%=Model.ForwardEnd %>;
            sss.CurrentLottery.OpenWinDelay = <%=Model.OpenWinDelay %>;
            sss.UI.IssueID = $("#Bet_IssueID");
            sss.UI.IssueName = $("#issuename");
            sss.UI.ContDown = $("#issueend");
            sss.UI.LastWin = $("#issuewin");
            sss.UI.Schemes = $("#buys");
            sss.UI.Chases = $("#chases");
            sss.UI.ChaseCbo = $("#Bet_Chase");
            sss.UI.SingleMultiply = $("#SingleMultiply");
            sss.UI.StopWin = $("#bet_chase_stopwin");
            sss.UI.SumCount = $("#bet_count");
            sss.UI.SumMoney = $("#bet_money");
            sss.UI.SumMoney_Post = $("#Bet_SumMoney");
            sss.UI.SubmitBtn = $("#btnBet");
            sss.UI.BetListCount = $("#BetListCount");
            sss.UI.OpenCodeHistory = $("#play_opencode_history");
            sss.UI.BackMoneyToWinMoney = $("#play_bet_backMoneyToWinMoney");
            
            var link = null;
            <% if(!Model.IsSinglePlay) %>
            <% { %>
            $("#play_bet_playtype a").click(function() {
                link = $(this);
                $("#play_bet_bar").load(this.href, null, function(html, status, xhr) {
                    try {
                        if (status == 'success') {
                            $("#play_bet_playtype li.current").removeClass("current");
                            link.parent().addClass("current");
                        } else {
                            return false;
                        }
                    } catch(ex) {
                        return false;
                    }
                });
                return false;
            });
            $("#play_bet_playtype li.current a").click();
            <% } %>

            sss.InitAndStart();
            var options =
                {
                    beforeSubmit: function(formData, jqForm, opts) {
                        var valid = jqForm.valid();
                        if (valid)
                            jqForm.block();
                        return valid;
                    },
                    success: function(result) {
                        if (result.Message) {
                            window.setTimeout(function() { alert(result.Message); }, 0);

                            if (result.State == true) {
                                var tp = $("#uer_balance")
                                var str = tp.text().replace(/[^\d\.]{1,}/, '');
                                var balance = _ParseDouble(str);
                                if (balance != null) {
                                    tp.text(tp.text().replace(/[\d\.]{1,}/, '') + (balance - Site.Lottery.Bet.SumMoney));
                                }
                                var num = Site.Lottery.Bet.UI.Chases.find(".head #issue_count").val(1);
                                Site.Lottery.Func.__Chases_title_startissue_set.call(num[0]);
                                Site.Lottery.Bet.UI.Schemes.find(".title #BetListDelete").click()
                            }
                        }
                    },
                    complete: function() {
                        $("#form_play_bet").unblock();
                    },
                    error: function() {
                        alert("请求失败，请稍后再试！");
                    }
                };
            $("#form_play_bet").ajaxForm(options);
        });
        function btnBet_Click() {
            var lotteryName = '<%=Model.LotteryName %>';
            var issuename = $('#issuename').text();
            var count = $('#bet_count').text();
            var multiply = $('.text_small').val();
            var money = $('#bet_money').text();
            var MyDS = lotteryName + ' ' + issuename + '\r\n' + '号码注数：' + count + '\r\n初始投注倍数:' + multiply
                + '倍\r\n投注金额：' + money + '元\r\n确认投注?';
            if ($('#Bet_Chase')[0].checked) {
                return confirm(MyDS);
            }

            if (count == '0注') {
                alert('请先选择号码');
                return false;
            }
            if (multiply == 0) {
                alert('请输入倍数');
                return false;
            } else {
                return confirm(MyDS);
            }
        }
    </script>
</asp:Content>